package com.qkjia.day03;

import java.util.concurrent.CyclicBarrier;

public class Test04_CyclicBarrier {
    public static void main(String[] args) {
        CyclicBarrier cyclicBarrier = new CyclicBarrier(10, () -> {
            System.out.println("大家一起去推塔");
        });
        for (int i = 0; i <10 ; i++) {
            new Thread(()->{
                try {
                    cyclicBarrier.await();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"\t就位");
            },""+i).start();
        }
    }
}
